// - 首页 `/`
// - 登录 `/login`
// - 注册 `/register`
// - 问卷管理
//     - 我的问卷 `/manage/list`
//     - 星标问卷 `/manage/star`
//     - 回收站 `/manage/trash`
// - 问卷详情
//     - 编辑问卷 `/question/edit/:id` （动态路由）
//     - 问卷统计 `/question/stat/:id`
// - 404

import MainLayout from "../Layout/MainLayout/MainLayout";
import ManagerLayout from "../Layout/ManagerLayout";
import QuestionLayout from "../Layout/QuestionLayout";

import Home from "../pages/Home/Home";
import NotFound from "../pages/NotFound/index";
import Login from "../pages/login/login";
import Register from "../pages/register/register";
import List from "../pages/Manage/List/List";
import Star from "../pages/Manage/star/star";
import Trash from "../pages/Manage/trash/trash";
import Edit from "../pages/question/edit/edit";
import Stat from "../pages/question/stat/stat";

import { createBrowserRouter } from "react-router-dom";

const router = createBrowserRouter([
  {
    path: "/",
    element: <MainLayout />,
    children: [
      {
        path: "/",
        element: <Home />,
      },
      {
        path: "login",
        element: <Login />,
      },
      {
        path: "register",
        element: <Register />,
      },
      {
        path: "/manage",
        element: <ManagerLayout />,
        children: [
          {
            path: "list",
            element: <List />,
          },
          {
            path: "star",
            element: <Star />,
          },
          {
            path: "trash",
            element: <Trash />,
          },
        ],
      },
      {
        path: "/question",
        element: <QuestionLayout />,
        children: [
          {
            path: "edit/:id",
            element: <Edit />,
          },
          {
            path: "stat/:id",
            element: <Stat />,
          },
        ],
      },
      {
        path: "*",
        element: <NotFound />,
      },
    ],
  },
]);
export default router;
//---------------//
export const HOME_PATH = "/";
export const LOGIN_PATH = "/login";
export const REGISTER_PATH = "/register";
export const MANAGE_PATH_LIST = "/manage/list";

export function isLoginOrRegister(pathname: string) {
  if ([LOGIN_PATH, REGISTER_PATH].includes(pathname)) {
    return true;
  }
  return false;
}

export function isNoNeedUserInfo(pathname: string) {
  if ([HOME_PATH, LOGIN_PATH, REGISTER_PATH].includes(pathname)) {
    return true;
  }
  return false;
}
